package vm.machine;

public class PushInstruction extends AbstractInstruction {
    private Object value;

    public PushInstruction(Machine machine, Object value) {
        super(machine);
        this.value = value;
    }

    @Override
    public void doAction() {
        if (value instanceof String) {
            machine.getStack().push(machine.getRegister((String) value).getValue());
        } else {
            machine.getStack().push((Integer) value);
        }
    }

    @Override
    public String toString() {
        return "执行Push指令";
    }
}
